package com.gao.c_publisher_subscribe;

import com.gao.App;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
 * @author gao
 * @time 2022/07/05 10:00:12
 */
@SpringBootTest(classes = App.class)
@RunWith(SpringRunner.class)
public class Producer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void test() throws InterruptedException {
        for (int i = 1; i <= 10; i++) {
            String msg = "Andy" + i;
            rabbitTemplate.convertAndSend("logs", "", msg);
        }

        TimeUnit.SECONDS.sleep(3);

    }
}
